package com.zh.core.service.impl;

import com.zh.core.dao.CustomerDao;
import com.zh.core.entity.Customer;
import com.zh.core.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhaohui on 2019/8/11
 * Description:
 */
@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    CustomerDao customerDao;

    @Override
    public List<Customer> queryAllCustomer() {
        return customerDao.queryAllCustomer();
    }

    @Override
    public Map<String, Object> queryCustomerWithPage(int offset, int limit) {
        Map<String, Object> result = new HashMap<>();
        int total = customerDao.queryAllCustomerNum();
        List<Customer> customerList = customerDao.queryCustomerWithPage(offset, limit);
        result.put("total", total);
        result.put("rows", customerList);
        return result;
    }

    @Override
    public int queryAllCustomerNum() {
        return customerDao.queryAllCustomerNum();
    }
}
